﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Data.SqlClient;

namespace z.v {
	/// <summary>
	/// Interaction logic for Setting.xaml
	/// </summary>
	public partial class Setting : Window {
		public bool start = true;
		public Setting() {
			InitializeComponent();
		}
		public Setting(bool start=true) {
			this.start = start;
			InitializeComponent();
		}
		private void btnSave_Click(object sender, RoutedEventArgs e) {
			Properties.Settings.Default.ConnectSting = txtConnectString.Text;
			int i = 0;
			int.TryParse(txtGUID.Text, out i);
			Properties.Settings.Default.GUID = i;
			Properties.Settings.Default.Save();
			Application.Current.Shutdown();
			Process.Start(Application.ResourceAssembly.Location);
			e.Handled = true;
		}

		private void Window_Loaded_1(object sender, RoutedEventArgs e) {
			refresh();
		}

		private void btnDefault_Click(object sender, RoutedEventArgs e) {
			Properties.Settings.Default.Reset();
			Application.Current.Shutdown();
			Process.Start(Application.ResourceAssembly.Location);
			e.Handled = true;
		}

		public void refresh() {
			txtConnectString.Text = Properties.Settings.Default.ConnectSting;
			txtGUID.Text = Properties.Settings.Default.GUID.ToString();
		}

		private void Window_Closed_1(object sender, EventArgs e) {
		}

		private void Window_MouseDown_1(object sender, MouseButtonEventArgs e) {
			this.DragMove();
		}

		private void btnQuit_Click(object sender, RoutedEventArgs e) {
			Application.Current.Shutdown();
		}
	}
}
